<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html">

    <p:outputPanel id="edPanel" layout="block" style="margin: 50px 0;">
        <div class="table-top-panel">
            <p:graphicImage value="../../resources/img/icons/study.png"/>
            <p:outputLabel value="Studii" styleClass="table-label"/>
        </div>
        <h:form id="ed-formId">
            <p:dataTable id="edData" var="ed" value="#{skillsDataBean.educations}" editable="true"
                         emptyMessage="Nu sunt inregistrari pentru dosarul curent"
                         rowIndexVar="rowIndex" styleClass="data-table-style data-table-panel">

                <p:column headerText="Principal">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{ed.basic}"/>
                        </f:facet>

                        <f:facet name="input">
                            <p:selectBooleanCheckbox value="#{ed.basic}"/>
                        </f:facet>
                    </p:cellEditor>
                </p:column>

                <p:column headerText="Studii">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{ed.educationStudy.name}"/>
                        </f:facet>

                        <f:facet name="input">
                            <p:selectOneMenu value="#{ed.educationStudy}" required="true" style="width: 200px;"
                                             converter="#{objectMappingConverter}">
                                <f:selectItem itemLabel="Selectati tipul"/>
                                <f:selectItems var="et" value="#{skillsDataBean.educationStudies}"
                                               itemLabel="#{et.name}" itemValue="#{et}"/>
                            </p:selectOneMenu>
                        </f:facet>
                    </p:cellEditor>
                </p:column>

                <p:column headerText="Specialitatea">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{ed.educationSpecialty.name}"/>
                        </f:facet>

                        <f:facet name="input">
                            <p:selectOneMenu value="#{ed.educationSpecialty}" required="true" style="width: 200px;"
                                             converter="#{objectMappingConverter}">
                                <f:selectItem itemLabel="Selectati specialitatea"/>
                                <f:selectItems var="es" value="#{skillsDataBean.educationSpecialities}"
                                               itemLabel="#{es.name}" itemValue="#{es}"/>
                            </p:selectOneMenu>
                        </f:facet>
                    </p:cellEditor>
                </p:column>

                <p:column headerText="Institutia">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{ed.institutionName}"/>
                        </f:facet>

                        <f:facet name="input">
                            <p:inputText value="#{ed.institutionName}" required="true"/>
                        </f:facet>
                    </p:cellEditor>
                </p:column>

                <p:column headerText="Anul absolvirii">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{ed.graduationYear}"/>
                        </f:facet>

                        <f:facet name="input">
                            <p:inputText value="#{ed.graduationYear}" required="true"/>
                        </f:facet>
                    </p:cellEditor>
                </p:column>

                <p:column headerText="Categoria">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{ed.educationCategory.name}"/>
                        </f:facet>

                        <f:facet name="input">
                            <p:selectOneMenu value="#{ed.educationCategory}" required="true" style="width: 200px;"
                                             converter="#{objectMappingConverter}">
                                <f:selectItem itemLabel="Selectati categoria"/>
                                <f:selectItems var="ec" value="#{skillsDataBean.educationCategories}"
                                               itemLabel="#{ec.name}" itemValue="#{ec}"/>
                            </p:selectOneMenu>
                        </f:facet>
                    </p:cellEditor>
                </p:column>

                <p:column headerText="Actiuni" width="15%">
                    <p:rowEditor id="ed-row-editor"/>
                    <p:commandLink value="Delete" actionListener="#{skillsDataBean.deleteEducation(ed)}"
                                   update="edData"/>
                </p:column>

            </p:dataTable>

            <p:commandLink value="Adauga studii" actionListener="#{skillsDataBean.addNewEducation('ed-row-editor')}"/>
        </h:form>
    </p:outputPanel>

    <p:outputPanel id="mlPanel" layout="block" style="margin: 50px 0;">
        <div class="table-top-panel">
            <p:graphicImage value="../../resources/img/icons/language.png"/>
            <p:outputLabel value="Limbi moderne" styleClass="table-label"/>
        </div>
        <h:form id="ml-formId">
            <p:dataTable id="mlData" var="ml" value="#{skillsDataBean.modernLanguages}" editable="true"
                         emptyMessage="Nu sunt inregistrari pentru dosarul curent"
                         rowIndexVar="rowIndex" styleClass="data-table-style data-table-panel">

                <p:column headerText="Limba">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{ml.language.name}"/>
                        </f:facet>

                        <f:facet name="input">
                            <p:selectOneMenu value="#{ml.language}" required="true" style="width: 200px;"
                                             converter="#{objectMappingConverter}">
                                <f:selectItem itemLabel="Selectati limba"/>
                                <f:selectItems var="lang" value="#{skillsDataBean.languages}"
                                               itemLabel="#{lang.name}" itemValue="#{lang}"/>
                            </p:selectOneMenu>
                        </f:facet>
                    </p:cellEditor>
                </p:column>

                <p:column headerText="Nivel de cunoastere">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{ml.knowledgeLevel.name}"/>
                        </f:facet>

                        <f:facet name="input">
                            <p:selectOneMenu value="#{ml.knowledgeLevel}" required="true" style="width: 200px;"
                                             converter="#{objectMappingConverter}">
                                <f:selectItem itemLabel="Selectati nivelul"/>
                                <f:selectItems var="kl" value="#{skillsDataBean.knowledgeLevels}"
                                               itemLabel="#{kl.name}" itemValue="#{kl}"/>
                            </p:selectOneMenu>
                        </f:facet>
                    </p:cellEditor>
                </p:column>

                <p:column headerText="Actiuni" width="15%">
                    <p:rowEditor id="ml-row-editor"/>
                    <p:commandLink value="Delete" actionListener="#{skillsDataBean.deleteModernLanguage(ml)}"
                                   update="mlData"/>
                </p:column>

            </p:dataTable>

            <p:commandLink value="Adauga limbi moderne" actionListener="#{skillsDataBean.addNewModernLanguage('ml-row-editor')}"/>
        </h:form>
    </p:outputPanel>

</ui:composition>